<?php
require_once SOURCE_EXT_PATH . 'common/ModelLib.class.php';
class CampStudentClass extends E_camp_student
{
	public $Message;
}

class ShowInfoAction extends AppAction
{
	private $userInfo;
	function __construct()
	{
		parent::__construct ();
		$this->userInfo = UserSession::getUserInfo ();
		$this->checkLogin ();
	}
	public function index()
	{
		switch ($this->userInfo->Channel)
		{
			case 1 :
				Header ( "Location:  " . siteUrl ( "ShowInfo/camp" ) . "" );
				break;
			case 3 :
				Header ( "Location:  " . siteUrl ( "ShowInfo/fulltime" ) . "" );
				break;
			case 4 :
				Header ( "Location:  " . siteUrl ( "ShowInfo/lotus" ) . "" );
				break;
			default :
				break;
		}
		ViewData::$title = "学生报名情况详情";
		ViewData::$form_data = $this->userInfo;
		ViewData::$form_hint = $this->userInfo;
		if ($_POST)
		{
			$this->editInfo ();
		}
		BaseAction::loadView ( 'showInfo' );
	}
	
	public function camp()
	{
		ViewData::$title = "报名信息详情";
		$this->checkLogin ( 1 );
		require_once APP_LIB_PATH . 'campLib.php';
		$campLib = new CampLib ();
		ViewData::$form_hint = new RegisteCampClass();
		ViewData::$form_data = $campLib->getById ( $this->userInfo->Id );
		BaseAction::loadView ( "ShowInfoCamp" );
	}
	
	public function campedit()
	{
		ViewData::$title = "报名信息修改";
		$this->checkLogin ( 1 );
		require_once APP_LIB_PATH . 'campLib.php';
		$campLib = new CampLib ();
		ViewData::$form_hint = new RegisteCampClass();
		if($_POST){
			$campLib->checkEditForm ();
			if (! BaseAction::isObjectEmpty ( ViewData::$form_hint ))
			{
				BaseAction::loadView ( "ShowInfoCampEdit" );
			}
			try
			{
				$campLib->editLogic ( $this->userInfo->Id );
				Header ( "Location:  " . siteUrl ( 'ShowInfo/camp' ) . "" );
				exit;
			} catch ( Exception $e )
			{
				ViewData::$form_hint->Message = $e->getMessage ();
			}
		}
		ViewData::$form_data = $campLib->getById ( $this->userInfo->Id );
		BaseAction::loadView ( "ShowInfoCampEdit" );
	}
	public function fulltime()
	{
		ViewData::$title = "报名信息详情";
		$this->checkLogin ( 3 );
		require_once APP_LIB_PATH . 'fullTimeLib.php';
		$lib = new FullTimeLib();
		ViewData::$form_data = $lib->getById ( $this->userInfo->Id );
		BaseAction::loadView ( "ShowInfoFullTime" );
	}
	public function lotus()
	{
		ViewData::$title = "报名信息详情";
		$this->checkLogin ( 4 );
		require_once APP_LIB_PATH . 'lotusLib.php';
		$lib = new LotusLib ();
		ViewData::$form_data = $lib->getById ( $this->userInfo->Id );
		BaseAction::loadView ( "ShowInfolotus" );
	}
	
	private function checkLogin($channel = FALSE)
	{
		if (! $this->userInfo)
		{
			BaseAction::error ( "请您先登录系统" );
		}
		if ($channel)
		{
			if ($channel != $this->userInfo->Channel)
			{
				BaseAction::error ( "请您先登录系统" );
			}
		}
		return TRUE;
	
	}
/*	
	public function campedit()
	{
		$this->checkLogin ( 1 );
		require_once APP_LIB_PATH . 'campLib.php';
		$campLib = new CampLib ();
		ViewData::$form_data = $campLib->getById ( $this->userInfo->Id );
		ViewData::$form_hint = new CampStudentClass ();
		if ($_POST)
		{
			
			$campLib->checkForm ();
			if (! BaseAction::isObjectEmpty ( ViewData::$form_hint ))
			{
				BaseAction::loadView ( "ShowInfoCampEdit" );
			}
			try
			{
				$campLib->editLogic ( $this->userInfo->Id );
				Header ( "Location:  " . siteUrl ( "ShowInfo/camp" ) . "" );
			} catch ( Exception $e )
			{
				ViewData::$form_hint->Message = $e->getMessage ();
			}
		}
		BaseAction::loadView ( "ShowInfoCampEdit" );
	}*/
}